<template>
  <el-form ref="form" :model="form" label-width="80px">
    <el-form-item label="群组名称">
      <el-input v-model="form.group_name" placeholder="为您的群组起一个响亮的名字吧"></el-input>
    </el-form-item>
    <el-form-item label="群组号码">
      <el-input v-model="form.group_id" placeholder="可以是数字字母/必须是唯一的"></el-input>
    </el-form-item>
    <el-form-item label="群组地址">
      <el-input v-model="form.address" placeholder="填写正确的地址，看看您附近都有哪些群组"></el-input>
    </el-form-item>
    <el-form-item label="群组介绍">
      <el-input type="textarea" v-model="form.desc"></el-input>
    </el-form-item>
    <div style="text-align: center">
      <el-button type="primary" @click="onSubmit">创建群组</el-button>
    </div>
  </el-form>
</template>
<script>
  import { groupCreate } from '@/public/api'

  export default {
    data () {
      return {
        checked: false,
        formLabelWidth: '120px',
        form: {
          group_name: '',
          group_id: '',
          category: '',
          address: '',
          set: [],
          resource: '',
          desc: ''
        }
      }
    },
    methods: {
      onSubmit () {
        groupCreate({
          user_id: this.User_id,
          group_id: this.form.group_id,
          name: this.form.group_name,
          detail_address: this.form.address,
          desc: this.form.desc
        }).then(
          data => {
            if (data.status) {
              this.$message('创建成功')
              this.$emit('close')
            }
          }
        )
      }
    },
    computed: {
      User_id () {
        return this.$store.state.user_id
      }
    }
  }
</script>
<style>

</style>
